#@embedLayout()


#define content()

<form id="formId" method="post">
    <input type="hidden" name="userId" id="userId" value="#(user.userId)">
    <table class="table table-bordered">
        <tr>
            <td style="padding-top:15px;">#(_res.get('user.form.oldpassword')):</td>
            <td><input type="text" id="oldPwd" name="oldPwd" class="easyui-passwordbox"
                       data-options="required:true,validType:{length:[6,32]}">
            </td>
        </tr>
        <tr>
            <td style="padding-top:15px;">#(_res.get('user.form.newpassword')):</td>
            <td><input type="text" id="newPwd" name="newPwd" class="easyui-passwordbox"
                       data-options="required:true,validType:{length:[6,32],password:''}">
            </td>
        </tr>
        <tr>
            <td>#(_res.get('user.form.confirmpassword')):</td>
            <td><input type="text" class="easyui-passwordbox" id="confirmPassword" name="confirmPassword"
                       data-options="required:true,validType:{length:[6,32],same:['newPwd'],password:''}">
            </td>
        </tr>
    </table>
</form>

#end


#define css()


#end


#define js()

<script type="text/javascript" src="#(ctx)/static/js/crypto-js.js"></script>

<script type="text/javascript">
    function updatePassword() {
        var url = contextRootPath + '/user/updatePwd';

        $('#formId').form('submit', {
            url: url,
            onSubmit: function () {
                var flag = $(this).form('enableValidation').form('validate');
                if (flag) {
                    showProcess(true, '温馨提示', '正在提交数据...');

                    $("#oldPwd").passwordbox('setValue', CryptoJS.MD5($("#oldPwd").passwordbox('getValue')).toString());
                    $("#newPwd").passwordbox('setValue', CryptoJS.MD5($("#newPwd").passwordbox('getValue')).toString());
                    $("#confirmPassword").passwordbox('setValue', CryptoJS.MD5($("#confirmPassword").passwordbox('getValue')).toString());
                }
                return flag;
            },
            success: function (data) {
                showProcess(false);

                if (!data.flag) {
                    $("#oldPwd").passwordbox('setValue', '');
                    $("#newPwd").passwordbox('setValue', '');
                    $("#confirmPassword").passwordbox('setValue', '');
                }

                var params = {};
                params.data = data;
                resultCallback(params);
            },
            onLoadError: function () {
                showProcess(false);
                $.messager.alert('温馨提示', '由于网络或服务器太忙，提交失败，请重试！');
            }
        });
    }

</script>

#end


